﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ET.Entity;
using ET.DbUtility;
using System.Data.SqlClient;

namespace ET.DataAccess
{
    public class DaEmployeeInfo
    {
        public EtEmployeeInfo CheckUser(string username, string password)
        {
            string sql = "SELECT * FROM EtEmployeeInfo " +
                " WHERE Username = '" + username +
                "' AND Password = '" + password + "' AND IsDeleted = 0";
            return EtSqlEntityHelper<EtEmployeeInfo>.GetEntity(sql);
        }

        public List<EtEmployeeInfo> GetAllUnDeleted()
        {
            string sql = "SELECT * FROM EtEmployeeInfo WHERE IsDeleted = 0";
            return EtSqlEntityHelper<EtEmployeeInfo>.GetEntitySet(sql);
        }

        public int Insert(EtEmployeeInfo employeeInfo)
        {
            string sql = string.Format("INSERT INTO EtEmployeeInfo(EmployeeName, Username, Password) " +
                " VALUES(@EmployeeName, @Username, @Password)");
            SqlParameter[] param = 
            {
                new SqlParameter("@EmployeeName", employeeInfo.EmployeeName),
                new SqlParameter("@Username", employeeInfo.Username),
                new SqlParameter("@Password", employeeInfo.Password),
            };
            return EtSqlHelper.ExecuteNonQuery(sql, param);
        }
    }
}
